//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    tabIndex:0,
    showOpen:false,
    list:[],//数据列表
    page:1,//加载到第几页,
    totalPage:0,//总页数

  },
  onLoad(){

  },
  onShow(){
    this.setData({
      page:1,
      list:[]
    })
    this.getData()
  },
  getData(){
    let url,
        tabIndex = this.data.tabIndex,
        page=this.data.page;
    if(tabIndex == 0) url = 'activity/remind/queryInuseList';
    if(tabIndex == 1) url = 'activity/remind/queryUnuseList';
    if(tabIndex == 2) url = 'activity/remind/queryUseupList';
    app.post(url,{
      page:this.data.page
    }).then(res=>{
      console.log(res)
      let list = this.data.list;
      this.setData({
        list:list.concat(res.list)
      })
      if(page == 1){
        this.setData({
          totalPage:res.pagination
        })
      }
    })
  },
  // 切换顶部导航栏
  changeTab(e){
    let type = e.target.dataset.type;
    this.setData({
      tabIndex:type
    })
  },
  // 未开启状态，点击开启按钮切换
  changeOpen(){
    this.setData({
      showOpen:!this.data.showOpen
    })
  },
  // 跳转页面
  goPage(e){
    let url = e.currentTarget.dataset.url;
    console.log(url)
    wx.navigateTo({
      url: `/pages/${url}/index`,
    })
  }
})
